<?php

namespace App\Http\Controllers\Backend;

use App\Http\Controllers\Controller;
use App\Models\About;

class AboutController extends Controller
{
    public function create()
    {
        $about = About::first();
        return view('about.create')->with(['about' => $about]);
    }

    public function store()
    {
        $model = \DB::transaction(function () {
            $attributes = request()->input();
            $about = About::first();
            $model = is_null($about) ? About::create($attributes) : $about->update($attributes);
            return $model;
        });
        return redirect()->route('about.create')->with('success', '添加成功');
    }
}